Skip to content

x11bridge: tolerate redundant GEM close for multi-plane DRI3 buffers#231

Open
aford173 wants to merge 1 commit into
AsahiLinux:mainfrom
aford173:adamford/dri3-multiplane-gem-double-close
Open

x11bridge: tolerate redundant GEM close for multi-plane DRI3 buffers#231
aford173 wants to merge 1 commit into
AsahiLinux:mainfrom
aford173:adamford/dri3-multiplane-gem-double-close

Conversation

@aford173

Copy link
Copy Markdown

A DRI3 PixmapFromBuffers request for a multi-plane buffer (or any buffer whose planes share one backing object) passes several dma-buf fds that all resolve to the same virtgpu GEM handle, because drm_prime_fd_to_handle deduplicates imports of the same underlying object. vgpu_id_from_prime creates one GemHandleFinalizer per fd, so once the request has been forwarded the bridge calls drm_gem_close on that handle once per fd. The first close frees the handle; each subsequent close of the now-invalid handle returns EINVAL (ENOENT on some drivers), which propagated out of process_socket and tore down the entire X11 client connection.

This is easy to hit with the Intel iris native context, which hands DRI3 a multi-plane (CCS-aux) buffer: glmark2 and other GL clients died with "XIO: fatal IO error 95 ... after 38 requests" the moment the first frame's pixmap was finalized.

Treat EINVAL/ENOENT from the redundant close as success: the handle is already gone, which is exactly the intended outcome.

Tested on an Intel Raptor Lake-U iGPU (8086:a721) with the iris native context, with the host iGPU bound to both the i915 and the xe kernel driver: before this change every GL client died with the XIO 95 above; after it, glmark2 runs to completion on both drivers (GL_RENDERER "Mesa Intel(R) Graphics (RPL-U)", clean exit, no finalizer/XIO errors). The fix is host-driver-independent, as the offending close is against the guest virtio-gpu device.

Comment thread crates/muvm/src/guest/bridge/common.rs Outdated
@aford173 aford173 force-pushed the adamford/dri3-multiplane-gem-double-close branch from fc278f8 to f70ae41 Compare June 30, 2026 13:50
@aford173 aford173 requested a review from teohhanhui June 30, 2026 13:51
Comment thread crates/muvm/src/guest/bridge/common.rs Outdated
Comment thread crates/muvm/src/guest/bridge/common.rs Outdated
Comment thread crates/muvm/src/guest/bridge/common.rs Outdated
@aford173 aford173 force-pushed the adamford/dri3-multiplane-gem-double-close branch from f70ae41 to e333416 Compare June 30, 2026 16:36
@aford173 aford173 requested a review from teohhanhui June 30, 2026 16:37
Comment thread crates/muvm/src/guest/bridge/common.rs Outdated
@teohhanhui

Copy link
Copy Markdown
Collaborator

CI failures seem unrelated. /cc @slp

@aford173 You need to fix the commit message to include the required Signed-off-by: ... signature.

@aford173 aford173 force-pushed the adamford/dri3-multiplane-gem-double-close branch from e333416 to ea44604 Compare June 30, 2026 16:54
A DRI3 PixmapFromBuffers for a multi-plane buffer (or any buffer whose
planes share one backing object) passes several dma-buf fds that all
resolve to the same virtgpu GEM handle, since drm_prime_fd_to_handle
deduplicates imports of the same object. vgpu_id_from_prime creates one
GemHandleFinalizer per fd, so the bridge calls drm_gem_close on that
handle once per fd. The first close frees it; each redundant close
returns EINVAL (ENOENT on some drivers), which propagated out of
process_socket and tore down the whole X11 client.

Refcount the live finalizers per handle: vgpu_id_from_prime increments
on import and finalize decrements, closing only when the last one runs.
This makes the redundant close impossible rather than swallowing its
error, so genuine drm_gem_close errors are still propagated.

The Intel iris native context hands DRI3 a multi-plane CCS-aux buffer
and was affected: every GL client (glmark2 and others) died with "XIO:
fatal IO error 95" on the first frame, now they run to completion.
Tested on an Intel Raptor Lake-U iGPU (8086:a721), host iGPU bound to
both i915 and xe. AMD (Strix Point) and Mali (MediaTek MT8196) do not
pass multi-plane buffers this way and were unaffected. The fix is
host-driver-independent, as the offending close is against the guest
virtio-gpu device.

Signed-off-by: Adam Ford <adam.ford@anodize.com>
@aford173 aford173 force-pushed the adamford/dri3-multiplane-gem-double-close branch from ea44604 to 6530142 Compare June 30, 2026 16:56
@aford173

Copy link
Copy Markdown
Author

CI failures seem unrelated. /cc @slp

@aford173 You need to fix the commit message to include the required Signed-off-by: ... signature.

Thanks for the reminder. Sorry about that. I added it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants